<?php namespace Home\Controller;

use Hdphp\Controller\Controller;
use \Common\Model\Job;

//首页控制器
class IndexController extends Controller{

    //显示首页
    public function index(){
    	//获得职位和公司信息
    	$jobModel=new Job;
    	$data=$jobModel
    		->join('company','lg_company_gsid','=','gsid')
    		->where("online=1")
    		->orderBy('jobsendtime','DESC')
            ->limit(8)
    		->get();
        //查询被收藏较多的职位
        $usrJobModel=new \Common\Model\UserJob;
        $jidsArr=Db::select("select lg_job_jid,count(*) as num from lg_user_job group by lg_job_jid order by num desc limit 8");
        $hotData=[];
        foreach ($jidsArr as $v) {
            $hotData[]=$jobModel->join('company','lg_company_gsid','=','gsid')->where("jid={$v['lg_job_jid']}")->find();
        }
        //友情链接
        $linkModel=new \Common\Model\Link;
        $linkData=$linkModel->get();
        View::with('linkData',$linkData);
        View::with('hotData',$hotData);
    	View::with('data',$data);
        View::make();
    }
}
